package com.xw.controller.api;

import com.google.common.collect.Maps;
import com.xw.common.Const;
import com.xw.service.VideosItemService;
import com.xw.util.AppUtil;
import com.xw.util.JsonData;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/api/videosItem/")
public class ApiVideosItemController {

    @Resource
    private VideosItemService videosItemService;

    /**
     * 查询课程下的视频
     * @param userId    用户id
     * @param videoId   课程id
     * @return
     */
    @PostMapping("findItemByVideoId")
    public Object findItemByVideoId(String userId,String videoId){
        Map map  = Maps.newHashMap();
        map.put("userId",userId);
        map.put("videoId",videoId);
        String str = AppUtil.checkIsNull(map);
        if (!str.equals(Const.SUCCESS_CODE_STR)) {
            return JsonData.fail(Const.parameterError(str));
        }
        map.clear();
        map = videosItemService.findItemByVideoId(userId,videoId);
        return map;
    }
}
